package com.dragon.app.design.pattern.singleton;

import java.util.Date;

/**
 * 
 * <p>class: Singleton3</p>  
 * <p>Description: 单例模式 双重检测锁DCL方式实现</p>  
 * @author SmallDragon
 * @date 2019年3月26日
 *
 */
public class Singleton3 {
	
	/**
	 * 在多线程环境下有极低的概率发生异常
	 */
	private static Singleton3 instance;
	/**
	 * volatile保证在多线程环境下的有序性
	 */
//	private static volatile Singleton3 instance; 
	
	private Date a;
	private Date b;
	private Date c;

	private Singleton3() {
		a = new Date();
		b = new Date();
		c = new Date();
	}

	public static Singleton3 getInstance() {
		if (instance == null) {
			synchronized (Singleton3.class) {
				if (instance == null) {
					instance = new Singleton3();
				}
			}
		}
		return instance;
	}

	public Date getA() {
		return a;
	}

	public void setA(Date a) {
		this.a = a;
	}

	public Date getB() {
		return b;
	}

	public void setB(Date b) {
		this.b = b;
	}

	public Date getC() {
		return c;
	}

	public void setC(Date c) {
		this.c = c;
	}

}
